#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1005;

int n, m;
ll a[N], b[N];
ll c[N];
ll dp[N];
bool check(ll x) {
  rep(i, 1, n) c[i] = a[i] - b[i] * x;
  rep(i, 1, m) dp[i] = -1e18;
  rep(i, 1, n) { per(j, m, 1) dp[j] = max(dp[j], dp[j - 1] + c[i]); }
  return dp[m] >= 0;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  while ((cin >> n >> m) && n) {
    m = n - m;
    rep(i, 1, n) cin >> a[i];
    rep(i, 1, n) cin >> b[i];
    rep(i, 1, n) a[i] *= 1000;
    int l = 0, r = 1000;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (check(mid))
        l = mid + 1;
      else
        r = mid - 1;
    }
    cout << (r + 5) / 10 << endl;
  }
  return 0;
}